<template>
<view  style="margin-top: 100px;">
  <uni-card >
<view style="background-color: 
#029d94; border-radius: 10px;
padding: 10px; color: #fff;">
 <p style="text-align: center; font-size: 24px;"> 答题完成！</p>
<view style="display: flex;">
  <view style="width: 40%;">
   
	<p>总计：{{ datas.index }}题</p>
	<p>答对：{{ datas.dui }}题</p>
  <p>答错：{{ datas.cuo }}题</p>

  <p>用时：{{ datas.time }}秒</p>
  </view>
  <view style="font-size: 24px;
  padding: 20px;
  ">
    总分：<text style="color: #ff79c6;">{{ Math.floor(datas.fenshu)  }}</text>
  </view>
</view>
</view>

</uni-card>

<view style="display: flex;">
  
  <button @click="fan" size="default" type="default" 
	style="color:#ffffff; backgroundColor:#029d94;borderColor:#029d94" 
	hover-class="is-hover">返回主页</button>
  <button @click="huil" size="default" type="default" 
	style="color:#ffffff; backgroundColor:#0062cc;borderColor:#0062cc" 
	hover-class="is-hover">试题回看</button>
</view>
</view>
</template>

<script setup lang="ts">
 import {
    onMounted,
    ref,
    getCurrentInstance
  } from 'vue';

  const fan=()=>{
    uni.switchTab(
      {
	url: '../../pages/index/index'
}
    )
  }
let datas =ref({
index:0,
dui:0,cuo:0,
time:0,
fenshu:0
});


const huil=()=>{
  uni.navigateTo({
  url: `/subpkg/huikan/index`,
  success: function(res:any) {
    // 通过eventChannel向被打开页面传送数据
    res.eventChannel.emit('acceptDataFromOpenerPage', 
    
    { datas
     })
  }
 
})
}
  onMounted(() => {
    const instance = getCurrentInstance()?.proxy
    // @ts-ignore
    const eventChannel = instance.getOpenerEventChannel();
    
  
    
  
    
    eventChannel.on('acceptDataFromOpenerPage', function(data:any) {
      datas.value=data
      console.log('acceptDataFromOpenerPage', data)
    })
  })
</script>

<style scoped></style>